/**
 * 全站权限配置
 *
 */
import router from './router'
// import Layout from './layout/index'
// import getDynamicRouter from '../../modularize/util/dymamicRouting'
router.beforeEach((to, from, next) => {
  if (to.path === '/login') {
    //如果登录成功访问登录页跳转到主页
    next({ path: '/' })
  } else {
    next()
  }
})
// function getRequire(path) {
//   return require(`@projects/manager/views${path}.vue`).default
// }
router.onReady((to, from) => {
  // store.dispatch('GetMenu', '0008').then(async (data) => {
  //   if (to.path === '/') {
  //     let paths = ''
  //     if (data.length !== 0) {
  //       if (data[0].children.length !== 0) {
  //         paths = data[0].children[0].path
  //       } else {
  //         paths = data[0].path
  //       }
  //     }
  //     router.push({ path: paths })
  //   } else {
  //     router.push({ path: to.path })
  //   }
  //   router.addRoutes(getDynamicRouter(Layout, data, '', getRequire))
  // })
})
router.afterEach(() => {})
